using Assets.Scripts.Map.Room;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.iOS;
using static UnityEditor.Progress;

public enum DebugGizmos
{
    Invisible,
    Visible,
}
public class RoomTileVisualization : MonoBehaviour
{
    [SerializeField]
    private DungeonManager dungeonManager;
    [SerializeField]
    private DebugGizmos debugGizmos = DebugGizmos.Invisible;
    [SerializeField]
    private List<RoomTileTypeColor> roomTileTypeColorList;
    [SerializeField]
    private List<RoomTypeColor> roomTypeColorList;
    private Dictionary<TileType, Color> roomTileTypeColorDict = new Dictionary<TileType, Color>();
    private Dictionary<RoomType, Color> roomTypeColorDict = new Dictionary<RoomType, Color>();

    public void OnFinishRoomCreate()
    {
        roomTileTypeColorDict.Clear();
        foreach (var item in roomTileTypeColorList)
        {
            roomTileTypeColorDict.Add(item.type, item.color);
        }
        roomTypeColorDict.Clear();
        foreach (var item in roomTypeColorList)
        {
            roomTypeColorDict.Add(item.type, item.color);
        }

    }
    public void OnDrawGizmosSelected()
    {
        if (dungeonManager == null || debugGizmos == DebugGizmos.Invisible || roomTileTypeColorDict.Count == 0) return;
        foreach (var room in dungeonManager.Rooms)
        {
            foreach (var tileType in room.TilesMap.Keys)
            {
                Gizmos.color = roomTileTypeColorDict[tileType];
                foreach (var pos in room.TilesMap[tileType])
                {
                    Gizmos.DrawCube(pos + new Vector2(0.5f,0.5f), Vector2.one);
                }
            }
            Gizmos.color = roomTypeColorDict[room.CurRoomType];
            Gizmos.DrawSphere((Vector2)room.RoomCenterPos, 0.3f);
        }
    }

}
[Serializable]
public class RoomTileTypeColor
{
    [SerializeField]
    public TileType type;
    public Color color;
}
[Serializable]
public class RoomTypeColor
{
    [SerializeField]
    public RoomType type;
    public Color color;
}
